package com.ftg.learn.service.impl;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.ftg.learn.entity.Sku;
import com.ftg.learn.mapper.SkuMapper;
import com.ftg.learn.service.ISkuService;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.ftg.learn.util.PageEx;
import com.ftg.learn.util.PageUtils;
import com.ftg.learn.util.R;
import com.ftg.learn.vo.SKUListVo;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigDecimal;

/**
 * <p>
 * SKU 表 服务实现类
 * </p>
 *
 * @author 布衣
 * @since 2025-07-22
 */
@Service
public class SkuServiceImpl extends ServiceImpl<SkuMapper, Sku> implements ISkuService {


    @Resource
    private SkuMapper skuMapper;

    @Override
    public R<PageEx<SKUListVo>> list(String name, BigDecimal minPrice, BigDecimal maxPrice, Integer page, Integer size) {
        PageHelper.startPage(page, size);
        PageInfo<SKUListVo> pageInfo = new PageInfo<>(skuMapper.list(name, minPrice, maxPrice));
        return R.ok(PageUtils.convertToPageEx(pageInfo, page, size));
    }
}
